{{--头部--}}
<?php
$path = request()->path();
$activeUrl = url()->current();
// 约定：顶部导航结构按照栏目结构进行规划
$activeCateIds = [];
if (isset($category) && $category->id) {
    $activeCateIds = getActiveCateIds($category->id);
}
?>
<section id="header" class="jsp-container">
    <nav class="navbar navbar-expand-lg navbar-light ">
        <a class="navbar-brand" href="{{$siteConfig['domain']}}">
            <img src="{{$siteConfig['logo_image']}}" height="40" alt="{{$siteConfig['name']}}">{{$siteConfig['name']}}
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item  {{$path=='/'?'active':''}}">
                    <a class="nav-link" href="{{$siteConfig['domain']}}">{{__('common.home')}}</a>
                </li>
                {{--导航条：两级--}}
                @if (isset($navigationBar) && !empty($navigationBar))
                    @foreach ($navigationBar as $item)
                        @php($isTopActive=($activeUrl==$item['href']|| in_array($item['info_category_id'],$activeCateIds) ? 'active' :''))
                        <li class="nav-item {{isset($item['children'])?'dropdown':''}}   {{$isTopActive}}  ">
                            @if(isset($item['children']))
                                <a class="nav-link dropdown-toggle"
                                   {{$item['href_']}}
                                   {{$item['href_target_']}}
                                   {{$item['rel_']}}
                                   id="navbarDropdown{{$item['id']}}"
                                   role="button"
                                   data-toggle="dropdown"
                                   aria-expanded="false"
                                >
                                    {{$item['name']}}
                                </a>
                                <div class="dropdown-menu  mt-0" aria-labelledby="navbarDropdown{{$item['id']}}">
                                    @foreach ($item['children'] as $sub)
                                        @php($isSubActive=($activeUrl==$sub['href']|| in_array($sub['info_category_id'],$activeCateIds) ? 'active' :''))
                                        <a class="dropdown-item {{$isSubActive}}  "
                                            {{$sub['href_']}}
                                            {{$sub['href_target_']}}
                                            {{$sub['rel_']}}
                                        >
                                            {{$sub['name']}}
                                        </a>
                                    @endforeach
                                </div>
                            @else
                                <a class="nav-link"
                                    {{$item['href_']}}
                                    {{$item['href_target_']}}
                                    {{$item['rel_']}}
                                >
                                    {{$item['name']}}
                                </a>
                            @endif
                        </li>
                    @endforeach
                @endif
            </ul>
        </div>
    </nav>
</section>
